<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title></title>
        <script type="text/javascript" src="../../inc/ctx.jsp"></script>
        <script type="text/javascript" src="../js/g.js"></script>
        <script type="text/javascript" src="http://cdn.uuola.cn/js/jq.ztree.js"></script>
        <link href="http://cdn.uuola.cn/css/ztree.css" type="text/css" rel="stylesheet"/>
        <style type="text/css">
            div{padding:0px;margin:0px;font-size:12px;font-family:Tahoma;}
        </style>
    </head>
    <body>    
        <div>请选择最终节点类目</div>
            <ul id="catalogsTree" class="ztree"></ul>

        <script type="text/javascript">
            var asyncUrl = '../app/catalogs/list_factor.shtm';
            var infotype = ut.get('channeltype');
            if(va.isnull(infotype)){
                ut.m('板块参数错误.');
                asyncUrl='';
            };
            var setting = {
                async:{
                    autoParam:['cid=rid'],
                    enable: true,
                    type: "get",
                    url: asyncUrl,
                    otherParam:{'infotype':infotype,'colfilter':'colfitler','ztree':'y'},
                    dataType:'json',
                    dataFilter: filter
                },
                data:{
                    key: {
//                        name: "cname",
//                        title: "cname",
                        children:null
                    },
                    simpleData: {
                        enable: true,
                        idKey: "cid",
                        pIdKey: "rid",
                        rootPId: 0
                    }
                },
                callback: {
                    onClick: click
                }
            };
            
            function filter(treeId, parentNode, childNodes) {
                if (!childNodes) return null;
                for (var i=0, l=childNodes.length; i<l; i++) {
                    childNodes[i].isParent = childNodes[i].nodenum>0 ? true : false;
                    childNodes[i].name = '('+childNodes[i].cid+')'+childNodes[i].cname;
                }
                return childNodes;
            };
            
            function click(event, treeId, treeNode, clickFlag){
                var isParent = treeNode.isParent;
                if(!isParent){
                    window.parent.window.reloadCatData(treeNode.cid,treeNode.ctp);
                }
            };

            $(document).ready(function(){
                $.fn.zTree.init($("#catalogsTree"), setting);
            });
        </script>
    </body>
</html>